package com.loanapp.base.common.dto;

import com.loanapp.base.common.exception.BizExceptionEnum;

/**
 * 服务器响应结果对象
 * 
 * @author 巴明端
 *
 * @param <T>
 */
public class ResponseDto<T> {
	/**
	 * 服务器响应编号
	 */
	private int code;
	/**
	 * 服务器响应消息
	 */
	private String mesg;
	/**
	 * 服务器响应结果对象
	 */
	private T data;

	/**
	 * 构造函数
	 *
	 * @param code
	 * @param mesg
	 * @param data
	 */
	public ResponseDto(int code, String mesg, T data) {
		super();
		this.code = code;
		this.mesg = mesg;
		this.data = data;
	}

	public static ResponseDto build(BizExceptionEnum e) {
		return new ResponseDto(e.getCode(), e.getMessage(), null);
	}

	public static ResponseDto build(int code,String mesg) {
		return new ResponseDto(code, mesg, null);
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getMesg() {
		return mesg;
	}

	public void setMesg(String msg) {
		this.mesg = msg;
	}

	public T getData() {
		return data;
	}

	public void setData(T data) {
		this.data = data;
	}

}